<?php
class Novedades extends Doctrine_Record {
    public function setTableDefinition() {
        $this->setTableName('novedades');
    }
    
    public function setUp(){
        $this->hasMany('Imagen as imagenes', array(
            'local' => 'id',
            'foreign' => 'id_novedades'
        ));
    }
    
    public static function getInstance () {
        return Doctrine::getTable('Novedades')->find(1);
    }
    
    public function imagenes () {
        $q = Doctrine_Query::create()
            ->select('i.*')
            ->from('Imagen i')
            ->innerJoin('i.novedades n')
            ->where('n.id = '.$this->id)
            ->orderBy('i.orden');
        return $q->execute();
    }
}
?>